package network.exercise.exercise2;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-04-05
 * Time:19:50
 */
public class Sender {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket(9999);
        Scanner scanner = new Scanner(System.in);
        String question = scanner.nextLine();
        byte[] bytes = question.getBytes();
        DatagramPacket packet = new DatagramPacket(bytes,0,bytes.length,InetAddress.getLocalHost(),8888);
        socket.send(packet);

        byte[] buf = new byte[1024 * 54];
        packet = new DatagramPacket(buf,buf.length);
        socket.receive(packet);
        String data = new String(packet.getData(),0, packet.getLength());
        System.out.println(data);
        socket.close();
    }
}
